<template>
	<view class="content">
		<!-- 轮播图 -->
		<view class="banner-view">
			<swiper class="swiper" circular indicator-dots="true" autoplay="true" interval="2000" duration="500">
				<swiper-item v-for="(item, index) in detailInfo.objKeys" @click="clickBanner(item)" :key="item.index">
					<image :src="item" mode="widthFix"></image>
				</swiper-item>
			</swiper>
		</view>
		<!-- 位置信息 -->
		<view class="info-view">
			<view class="info-title">{{ detailInfo.routeName }}</view>	
			<!-- 详情介绍 -->
			<view class="descriotion-view">
				<rich-text :nodes="detailInfo.routeDesc" class="fload" :class="isFload ? 'hide' : 'show'"></rich-text>
				<view class="more-btn" @click="onFlag">{{ buttonText }}</view>
			</view>
			<!-- 周边推荐 -->
			<view class="recommend-view">
				<!-- <view class="recommend-title">周边推荐</view> -->
				<!-- 分类菜单 -->
				<!-- <view class="menu-view"></view> -->
				<!-- <van-tabs v-model="active" :change="onChange">
					<van-tab v-for="(item,index) in scheduleList" :title="item.scheduleName" :key="item.id" @click="itemClick(item,index)"></van-tab>
				</van-tabs> -->

				<uni-segmented-control :current="currentTab" :values="scheduleNameList" @clickItem="onChange" styleType="text" activeColor="#137576"></uni-segmented-control>
				<view class="recommend-list" v-for="(item, index) in travelList" :key="item.id">
					<view class="item-title">{{ item.itineraryName }}</view>
					<swiper class="sub-swiper" circular indicator-dots="true" autoplay="true" interval="2000" duration="500">
						<swiper-item v-for="(obj, index) in item.objKeys" @click="clickBanner()" :key="obj.index">
							<image :src="obj" mode="widthFix"></image>
						</swiper-item>
					</swiper>
					<view class="item-desc">
						<rich-text :nodes="item.itineraryDesc"></rich-text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getTravelRouteDetail } from '@/api/index.js';
export default {
	components: {},
	data() {
		return {
			id: '',
			active: 0,
			myImgList: [],
			// 文章详细信息
			// 用于控制展开收起
			isFload: false,
			buttonText: '',
			detailInfo: {},
			scheduleList: [],
			scheduleNameList: [],
			travelList: [],
			currentTab: 0
		};
	},
	mounted() {},
	onLoad(e) {
		this.id = e.id;
		this.getDetails(e.id);
		this.onFlag();
	},
	methods: {
		getDetails(id) {
			let that = this;
			this.myImgList = [];
			this.scheduleList = [];
			this.travelList = [];
			uni.showLoading({});
			getTravelRouteDetail(id).then((res) => {
				uni.hideLoading();
				console.log('游线详情数据：', res);
				if (res.data && res.code === 200) {
					that.detailInfo = res.data;
					that.myImgList = res.data.objKeys;
					that.scheduleList = res.data.travelScheduleDTOS;
					that.scheduleList.map((item) => {
						that.scheduleNameList.push(item.scheduleName);
					});
					console.log('myImgList:', that.myImgList);
					console.log('scheduleNameList:', that.scheduleNameList);
					that.travelList = res.data.travelScheduleDTOS[that.currentTab].travelItineraryDTOS;
				}
			});
		},
		goImgClick(item) {
			uni.showModal({
				title: '温馨提示',
				content: '点击图片带的数据= ' + JSON.stringify(item)
			});
		},
		onFlag() {
			if (this.isFload) {
				this.buttonText = '收起';
			} else {
				this.buttonText = '展开';
			}
			this.isFload = !this.isFload;
		},
		onChange(e) {
			this.currentTab = e.currentIndex;
			this.travelList = this.scheduleList[e.currentIndex].travelItineraryDTOS;
			console.log('travelList:', this.travelList);
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	height: 100%;
	position: relative;
}
.content {
	width: 100%;
	height: 100%;
	background-color: #fff;
}
.banner-view {
	/* display: flex;
	flex-direction: column; */
	align-items: center;
	justify-content: center;
	background-color: white;
	.swiper {
		height: 420rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
}

.info-view {
	padding: 20rpx 40rpx;
	background-color: #fff;
	border-top-left-radius: 40rpx;
	border-top-right-radius: 40rpx;
	position: relative;
	top: -40rpx;
}
.info-title {
	font-size: 36rpx;
	color: #137576;
	margin-bottom: 20rpx;
}
.descriotion-view {
	// 展开
	background-color: white;
	font-size: 14px;
	/* margin: 10px 0; */
	/* left: 10rpx;
	right: 10rpx;
	top: 10rpx; */
}
.fload {
	width: 100%;
	height: auto;
	display: -webkit-box;
	word-break: break-all;
	-webkit-box-orient: vertical;
	/* 要显示多少行就改变line-clamp的数据,此处折叠起来显示一行*/
	-webkit-line-clamp: 3;
	overflow: hidden;
	text-overflow: ellipsis;
	/* padding: 10px 10px 10 10px; */
	background-color: white;
}
.hide {
	display: -webkit-box;
}
.show {
	display: block;
}
.more-btn {
	display: block;
	height: 40px;
	color: #417275;
	text-align: center;
	line-height: 40px;
	width: 100%;
}
.recommend-view {
	background-color: white;
	margin: 10px 0;
}

.recommend-title {
	margin-left: 20px;
	padding-top: 20px;
	font-size: 20px;
}
.recommend-list {
	background-color: #fff;
	.sub-swiper {
		height: 320rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
}
.item-title {
	font-size: 32rpx;
	font-weight: bold;
	padding: 20rpx 0;
	position: relative;
	&::before{
	  content:'';
	  display: block;
	  width:10px;
	  height:10px;
	  background:#137576;
	  border-radius: 50%;
	  margin-right: 6px;
	  position: absolute;
	  left: -26rpx;
	  top: 40%;
	}
}
.item-desc {
	padding: 20rpx 0;
}
</style>
